package com.util;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

public class ParamUtil {

    public String getParamStr(HttpServletRequest request){
        /* 保存当前的资源路径和参数 */
        //参数字符串
        StringBuilder param = new StringBuilder();
        //参数集合
        Map<String, String[]> parameterMap = request.getParameterMap();
        //遍历参数集合
        for (String paramName : parameterMap.keySet()){
            //获取参数数组
            String[] paramValue = parameterMap.get(paramName);
            //遍历参数数组
            for (int i = 0; i < paramValue.length; i++){
                param.append(paramName + "=" + paramValue[i] + "&");
            }
        }
        return param.toString();
    }
}
